<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<title>simReceiveData</title>
<link rel="stylesheet" type="text/css" href="../../style.css">
</head>

<body>

<div align="center">
<table class=allEncompassingTable >
 <tr>
  <td >
<p><a href="../../index.html" TARGET="_top"><img src="../images/homeImg.png"></a></p>

<h1><a href="../apiOverview.htm">Regular API</a> function</h1>
<h3 class=subsectionBar><a name="simReceiveData" id="simReceiveData"></a>simReceiveData / sim.receiveData </h3>
<table class=apiTable>
<tr class=apiTableTr> 
<td class=apiTableLeftDescr>
Description 
</td> 
<td class=apiTableRightDescr>Receives wireless data (in a simulation). See also <a href="simSendData.htm">sim.sendData</a> and <a href="simTubeOpen.htm">sim.tubeOpen</a>. Cannot be called from <a href="../addOns.htm">add-ons</a>.<br>
<br>
Wireless receptions can be visualized globally via the <a href="../environmentPropertiesDialog.htm">environment dialog</a>, or individually as in following example:
<pre class=lightRedBoxNoMarginAndSmall>
sim.setBoolParameter(sim.boolparam_force_show_wireless_reception,true)
data=sim.receiveData(...)
sim.setBoolParameter(sim.boolparam_force_show_wireless_reception,false)</pre></td>
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftCSyn>
C synopsis
</td> 
<td class=apiTableRightCSyn>simReceiveData(simInt dataHeader,const simChar* dataName,simInt antennaHandle,simInt index,simInt* dataLength,simInt* senderID,simInt* dataHeaderR,simChar** dataNameR)<br></td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftCParam>C parameters</td> 
<td class=apiTableRightCParam>
<div><strong>dataHeader</strong>: number indicating who &quot;designed&quot; the communication message. Can also be -1, in which case messages with any dataHeader will be retrieved (not recommended, unless index is different from -1). </div>
<div><strong>dataName</strong>: name indicating the type of message. Can be nil, in which case messages with any dataName will be retrieved (not recommended, unless index is different from -1)<br>
</div>
<div><strong>antennaHandle</strong>: handle of the scene object that should operate as the antenna for this reception. If sim_handle_default is specified, a reception antenna at (0,0,0) is simulated.<br>
</div>
<div><strong>index</strong>: zero-based index of the message to read. If -1 is indicated, the first message that matches the dataHeader and dataName is read and removed. Otherwise messages are just read.<br>
</div>
<div><strong>dataLength</strong>: length of the received data (if returned pointer is not nullptr)<br>
</div>
<div><strong>senderID</strong>: identifier of the sender. Can be the handle of a script if the message was sent from a script, or can be 0 if the message was sent from the non-Lua API. Can be nullptr.<br>
</div>
<div><strong>dataHeaderR</strong>: dataHeader of the data that was read. Can be nullptr.</div>
<div><strong>dataNameR</strong>: dataName of the data that was read. Can be nullptr. The user is in charge of releasing the buffer with <a href="simReleaseBuffer.htm">simReleaseBuffer</a>(*dataNameR).<br>
</div>
</td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftCRet>
C return value
</td> 
<td class=apiTableRightCRet>
<div>pointer to the received data, or nullptr if no data is available or in case of an error. The user is in charge of releasing the returned buffer with <a href="simReleaseBuffer.htm">simReleaseBuffer</a>.<br>
</div>
</td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftLSyn>
Lua synopsis
</td> 
<td class=apiTableRightLSyn>string data,number senderID,number dataHeader,string dataName=sim.receiveData(number dataHeader=-1,string dataName=nil,number antennaHandle=sim.handle_self,number index=-1)<br></td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftLParam>Lua parameters</td> 
<td class=apiTableRightLParam>
<div><strong>dataHeader</strong>: number indicating who &quot;designed&quot; the communication message. Can also be -1, in which case messages with any dataHeader will be retrieved (not recommended, unless index is different from -1). This value can be omitted (-1 will be used).</div>
<div><strong>dataName</strong>: name indicating the type of message. Can be nil, in which case messages with any dataName will be retrieved (not recommended, unless index is different from -1). This value can be omitted (nill will be used)<br>
</div>
<div><strong>antennaHandle</strong>: handle of the scene object that should operate as the antenna for this reception. If sim.handle_default is specified, a reception antenna at (0,0,0) is simulated. If sim.handle_self is specified, the object associated with the current child script is used as the antenna. This value can be omitted (sim.handle_self will be used)<br>
</div>
<div><strong>index</strong>: zero-based index of the message to read. If -1 is indicated, the first message that matches the dataHeader and dataName is read and removed. Otherwise messages are just read. This value can be omitted (-1 will be used)</div>
</td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftLRet>
Lua return values
</td> 
<td class=apiTableRightLRet>
<div><strong>data</strong>: string containing the received data, or nil if no data is present. If received data is packed, see also the <a href="../apiFunctionListCategory.htm#packing">data packing/unpacking functions</a></div>
<div><strong>senderID</strong>: identifier of the sender. Can be the handle of a script if the message was sent from a script, or can be 0 if the message was sent from the non-Lua API.<br>
</div>
<div><strong>dataHeader</strong>: dataHeader of the data that was read.<br>
</div>
<div><strong>dataName</strong>: dataName of the data that was read.</div>
</td> 
</tr> 
</table> 

<br>
<p><a href="../apiFunctions.htm">All regular API functions on one page</a></p>
<br>
<br>
</td>
</tr>
</table>
</div>
</body>
</html>
